package cn.sumpu.app.guoguojie.biz;

import java.awt.Color;
import java.awt.Font;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;



import cn.sumpu.app.guoguojie.exception.AppBusinessException;
import cn.sumpu.app.guoguojie.util.ImageWeb;

public interface ImageBiz {

    public ImageWeb cutAvatar(String imageServer, String srcImgPath, String destDir, String imageName, int xCoords, int yCoords, int destWidth, int destHeight,
                              int divWidth, int divHeight, int tagWidth, int tagHeight, String pageType) throws AppBusinessException;

    public String makeThumbnail(String srcImgPath, Map<String, Object> settings) throws AppBusinessException;

    public String makeThumbnail(String srcImgPath, int thumbnailWidth, int thumbnailHeight, int maxThumbnailWidth, int maxThumbnailHeight)
                                                                                                                                          throws AppBusinessException;

    public void makeWatermark(String waterText, String targetImg, Font font, Color color, int watermarkPos) throws AppBusinessException;

    public void makeWatermark(String waterImg, String targetImg, int watermarkPos) throws AppBusinessException;

    public void upload(HttpServletRequest request) throws AppBusinessException;

    public ImageWeb uploadOneImg(HttpServletRequest request) throws AppBusinessException;

    public boolean checkUploadSize(HttpServletRequest request) throws AppBusinessException;

    /**
     * 请求把图片保存到图片服务器.
     * 
     * @param serverUrl
     *            图片服务器的URL，比如：http://127.0.0.1:80/receiveImage.htm
     * @param savePath
     *            图片要保存在图片服务器上的路径（相对于webapp的路径），比如：tmp/pic
     * @param saveFilename
     *            图片要保存在图片服务器上的文件名，比如：123456789.jpg
     * @param imageData
     *            图片数据（byte数组）
     * @throws AppBusinessException
     *             如果发送图片的过程中出现问题，抛出此异常
     */
    public void requestSaveImage(String serverUrl, String savePath, String saveFilename, byte[] imageData) throws AppBusinessException;

    /**
     * 保存图片.
     * 
     * @param in
     *            图片输入流
     * @param savePath
     *            图片要保存在图片服务器上的路径（相对于webapp的路径），比如：tmp/pic
     * @param saveFilename
     *            图片要保存在图片服务器上的文件名，比如：123456789.jpg
     * @throws AppBusinessException
     *             如果发送图片的过程中出现问题，抛出此异常
     */
    public void saveImage(byte[] in, String savePath, String saveFilename) throws AppBusinessException;

    /**
     * 请求从图片服务器上删除图片.
     * 
     * @param serverUrl
     *            图片服务器的URL，比如：http://127.0.0.1:80/deleteImage.htm
     * @param imageFile
     *            要删除的图片文件（相对于webapp的路径），比如：tmp/pic/uuid.jpg
     * @throws AppBusinessException
     *             如果删图片的过程中出现问题，抛出此异常
     */
    public void requestDeleteImage(String serverUrl, String imageFile) throws AppBusinessException;

    /**
     * 请求从图片服务器上删除图片.
     * 
     * @param serverUrl
     *            图片服务器的URL，比如：http://127.0.0.1:80/deleteImage.htm
     * @param imageFile
     *            要删除的图片文件（相对于webapp的路径），比如：tmp/pic/uuid.jpg
     * @throws AppBusinessException
     *             如果删图片的过程中出现问题，抛出此异常
     */
    public void requestDeleteImage(String imageFile) throws AppBusinessException;

    public void requestDeleteImageThumb(String imageFile) throws AppBusinessException;

    /**
     * 删除图片.
     * 
     * @param imageFile
     *            要删除的图片文件（相对于webapp的路径），比如：tmp/pic/uuid.jpg
     * @throws AppBusinessException
     *             如果删图片的过程中出现问题，抛出此异常
     */
    public void deleteImage(String imageFile) throws AppBusinessException;

    public ImageWeb cutImage(byte[] b, int tagWidth, int tagHeight, String savePath, String imageName) throws AppBusinessException;

    public void setWidthHeightPic() throws Exception;

    public void setWidthHeightPro() throws Exception;

    //	订正上传图片为320
    public void cut320Pic() throws Exception;

    //订正商品图片为320
    public void cut320Pro() throws Exception;

    //订正图片，删除不需要的图片
    public void correctImg() throws Exception;

    public ImageWeb uploadOneImg(HttpServletRequest request, String picType) throws AppBusinessException;
}
